import matplotlib.pyplot as plt
import numpy as np

# 数据
items = ['Total Assets', 'Current Assets', 'Non-Current Assets', 'Total Liabilities', 
         'Current Liabilities', 'Non-Current Liabilities', 'Shareholders\' Equity', 'Retained Earnings']
start_values = [7141490272.59, 3625353055.2, 3516137217.39, 4711600654.03, 
                2930059278.7, 1781541375.33, 2424931326.95, -21097995878.04]
end_values = [6179196278.99, 3212246780.01, 2966949498.98, 4675601873.4, 
              3226772338.45, 1448829534.95, 1498287188.33, -22037341403.67]
changes = [-13.47, -11.4, -15.03, -0.76, 10.11, -18.73, -38.21, 4.42]

# 定义x轴的位置
x = np.arange(len(items))  # the label locations
width = 0.35  # the width of the bars

fig, ax1 = plt.subplots()

# 绘制柱状图
rects1 = ax1.bar(x - width/2, start_values, width, label='Start of Year 2023', color='b')
rects2 = ax1.bar(x + width/2, end_values, width, label='End of Year 2023', color='r')

# 添加一些文字为标签、标题和自定义x轴刻度等
ax1.set_xlabel('Items')
ax1.set_ylabel('Values (RMB)', color='b')
ax1.set_title('Financial Data and Changes')
ax1.set_xticks(x)
ax1.set_xticklabels(items)
ax1.legend()

# 创建一个双轴
ax2 = ax1.twinx()

# 绘制折线图
ax2.plot(x, changes, label='Change (%)', color='g', marker='o')
ax2.set_ylabel('Change (%)', color='g')

# 添加图例
ax2.legend(loc='upper left')

# 显示图表
plt.show()